﻿using EFCoreToApi.BLL.IService;
using EFCoreToApi.BLL.Service;
using EFCoreToApi.Models;
using EFCoreToApi.Models.Model;
using EFCoreToApi.Redis;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;

namespace EFCoreToApi.Controllers
{
    /// <summary>
    /// 测试控制器
    /// </summary>
    [Route("api/[controller]")]
    [ApiController]
    public class testController : ControllerBase
    {
        /// <summary>
        /// 学生服务接口
        /// </summary>
        protected IStudentService _studentService;
        RedisContexts redisContexts = new RedisContexts();
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="studentService"></param>
        public testController(IStudentService studentService)
        {
            _studentService = studentService;
        }
        /// <summary>
        /// 获取所有学生信息
        /// </summary>
        /// <returns></returns>
        [HttpGet("getAllList")]
        public List<Student> getAllList()
        {
            return _studentService.getAllStudentsLists();
        }
        /// <summary>
        /// 获取redis数据
        /// </summary>
        /// <param name="Key"></param>
        /// <returns></returns>
        [HttpGet("getRedisValue")]
        public DateTime getRedisValue(string Key)
        {
            return redisContexts.Get<DateTime>(Key);
        }
        /// <summary>
        /// 获取redis List Key值
        /// </summary>
        /// <param name="Key"></param>
        /// <returns></returns>
        [HttpGet("getValue")]
        public string getValue()
        {
            return RedisKeyLists.RedisKeyName;
        }
    }
}
